package com.example.bes.springboot.web.war.fliter;

import cn.dev33.satoken.filter.SaFirewallCheckFilterForServlet;

import javax.servlet.*;
import java.io.IOException;

/**
 * 兼容 Servlet 3.1 的 Sa-Token Filter 包装器
 */
public class SaTokenFilterWrapper2 implements Filter {

    private final SaFirewallCheckFilterForServlet delegate = new SaFirewallCheckFilterForServlet();

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("[SaTokenFilterWrapper] init");
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws IOException, ServletException {
        // 手动代理调用
        delegate.doFilter(request, response, chain);
    }

    @Override
    public void destroy() {
        System.out.println("[SaTokenFilterWrapper] destroy");
    }
}
